package cn.edu.neu.lab603.cloudeval.entity.model.power

import cn.edu.neu.lab603.cloudeval.entity.{PhysicalMachine => Host}
import com.typesafe.scalalogging.LazyLogging

/** 能耗的经验模型。
  *
  * Created by yfwz100 on 16/9/25.
  */
class EmpiricalPowerModel(val idlePower: Long = 50,
                          val floatPower: Long = 50)
  extends PowerModel with LazyLogging {

  override def getPower(host: Host): Long = {
    val cpu = host.getUsedResPct.getOrElse("mips", 0.0)
    val cores = host.capacity("core")
    (Math.sqrt(cores) * (idlePower + floatPower * (2 * cpu - Math.pow(cpu, 0.7)))).toLong
  }
}
